<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"F:\phpStudy_NEW\PHPTutorial\WWW\public/../application/admin\view\user\admin.html";i:1525684276;}*/ ?>


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台管理员 </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
</head>
<body>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>用户</cite></a>
        <a><cite>系统用户</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">后台管理员列表</div>
                <div class="layui-card-body">
                    <div class="layui-btn-group admin-table-btn" style="margin-bottom: 10px;">
                        <button class="layui-btn" data-type="getCheckData">批量禁用</button>
                        <button class="layui-btn" data-type="getCheckLength">批量恢复</button>
                        <button class="layui-btn layui-btn-danger" data-type="isAll">批量删除</button>
                    </div>

                    <table class="layui-hide" id="admin-table" lay-filter="admin-table"></table>

                    <script type="text/html" id="table-bar">
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/admin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var table = layui.table
            ,admin = layui.admin;

        table.render({
            elem: '#admin-table'
            ,url: '/admin/user/admin.html'
            ,cols: [[
                {type:'checkbox', width:100,}
                ,{field:'id', title: 'ID', width:100, sort: true}
                ,{field:'uname', width:300, title: '用户名'}
                ,{field:'types', title: '级别', width:200, sort: true}
                ,{width:200, align:'center', toolbar: '#table-bar'}
            ]]
            ,page: true
        });

        //监听表格复选框选择
        table.on('checkbox(admin-table)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(admin-table)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('admin-table')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('admin-table')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('admin-table');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.admin-table-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>